import os.path
import time
import pytest
from .data import load_ecgUploaddata,baseurl
import allure
import requests
basedir=os.path.dirname(__file__)
filepath=os.path.join(basedir,"testCase/ecgUpload.json")
@allure.epic("心电数据上传接口")
class TestEcgUpload:
    def setup_class(self):
        print("心电数据上传接口测试开始：",time.strftime("%Y-%m-%d-%H:%M:%S"))
    def teardown_class(self):
        print("心电数据上传接口测试介绍：",time.strftime("%Y-%m-%d-%H:%M:%S"))
    @allure.story("小数据接口测试")
    @pytest.mark.parametrize("testCase,device_id,data,msg,status_code,timestamps",load_ecgUploaddata(filepath))
    @allure.title("{testCase}")
    def test_ecgUpload(self,testCase,device_id,data,msg,status_code,timestamps):
        self.url=f"{baseurl}/ecg_upload"
        data={
            "device_id":device_id,
            "data":data,
            "timestamps":timestamps
        }
        responses=requests.post(self.url,data=data)
        assert status_code==responses.status_code
        assert msg in responses.json().get("message")